//
//  ViewController.m
//  RequestDemo
//
//  Created by 红沙尘 on 17/4/20.
//  Copyright © 2017年 红沙尘. All rights reserved.
//

#import "ViewController.h"
#import "BIgeyesRequest+HSC.h"
#import "BIgeyesRequest+Python.h"
#import "LogViewController.h"
#import <AudioToolbox/AudioToolbox.h>
#import <CoreFoundation/CoreFoundation.h>
@interface ViewController ()<UITableViewDelegate,UITableViewDataSource>
{
    NSArray *array;
    __weak IBOutlet UITableView *myTableView;
}
@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    array = @[@"手机号唯一验证",@"发送验证码",@"注册",@"人脸检测",@"上传用户人脸",@"设置用户资料",@"",@"登录图片",@"登录验证码",
              @"获取最新token",@"退出",@"上传通讯录",@"搜索人脸",@"发送照片",@"自动发送照片",@"获取待确认照片",
              @"获取分享照片回执",@"拒绝照片",@"确认照片",@"获取好友",@"雷达搜索好友",@"加好友",
              @"设置项",@"邀请",@"图片上传"];

    [BIgeyesRequest bigeye_phone_number_checkAreaCode:@"86"
                                          phoneNumber:@"13345698578"
                                              success:^(NSDictionary *responseObject) {
                                                  
                                              } fail:^{
                                                  
                                              }];
    
    //TODO 发布时候删除摇一摇
//    // 设置允许摇一摇功能
//    [UIApplication sharedApplication].applicationSupportsShakeToEdit = YES;
//    // 并让自己成为第一响应者
//    [self becomeFirstResponder];
    
}

- (BOOL)canBecomeFirstResponder {//默认是NO，所以得重写此方法，设成YES
    return YES;
}


- (void)motionBegan:(UIEventSubtype)motion withEvent:(UIEvent *)event {
    NSLog(@"开始摇动");
    return;
}

- (void)motionCancelled:(UIEventSubtype)motion withEvent:(UIEvent *)event {
    NSLog(@"取消摇动");
    return;
}

- (void)motionEnded:(UIEventSubtype)motion withEvent:(UIEvent *)event {
    if (event.subtype == UIEventSubtypeMotionShake) { // 判断是否是摇动结束
        NSLog(@"摇动结束");

        AudioServicesPlaySystemSound (kSystemSoundID_Vibrate);

        UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:[[LogViewController alloc] init]];
        
        [self presentViewController:nav animated:YES completion:nil];
    }
    return;
}

#pragma mark - tableView 

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return array.count;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    return 45;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"BIgeyesCell"];
    
    if (!cell) {
        cell = [[UITableViewCell alloc] initWithStyle:0 reuseIdentifier:@"BIgeyesCell"];
    }
    
    cell.textLabel.text = [NSString stringWithFormat:@"%d、%@",(int)indexPath.row,array[indexPath.row]];
    
    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    
//    [BIgeyesRequest bigeye_phone_number_checkAreaCode:@"86"
//                                          phoneNumber:@"13345698578"
//                                              success:^(NSDictionary *responseObject) {
//                                                  
//                                              } fail:^{
//                                                  
//                                              }];
//    return;
    switch (indexPath.row) {
        case 0:
        {
            [BIgeyesRequest bigeye_phone_number_checkAreaCode:@"86"
                                                  phoneNumber:@"213345698578"
                                                      success:^(NSDictionary *responseObject) {
                                                          
                                                      } fail:^{
                                                          
                                                      }];
        }
            break;
            case 1:
        {
            [BIgeyesRequest verifyAreaCode:@"86"
                               phoneNumber:@"13345698578"
                                      type:VerifyType_SMS
                                   success:^(NSDictionary *responseObject) {
                
            } fail:^{
                
            }];
        }
            break;
        case 2:
        {
            [BIgeyesRequest userSignupAreaCode:@"86"
                                   phoneNumber:@"13345698578"
                                          code:@"1234"
                                       success:^(NSDictionary *responseObject) {
                
            } fail:^{
                
            }];
        }
            break;
            case 3:
        {
            [BIgeyesRequest faceDetect:@"" success:^(NSDictionary *responseObject) {
                
            } fail:^{
                
            }];
        }
            break;
            case 4:
        {
            [BIgeyesRequest faceUploadsessionId:@"" imageBase64:@"" imageType:@"" success:^(NSDictionary *responseObject) {
                
            } fail:^{
                
            }];
        }
            break;
            case 5:
        {
            [BIgeyesRequest userProfileSetWithIdentityId:@"" nickname:@"" success:^(NSDictionary *responseObject) {
                
            } fail:^{
                
            }];
        }
            break;

            case 7:
        {
            [BIgeyesRequest userLoginWithAreaCode:@"" phoneNumber:@"" imageBase64:@"" success:^(NSDictionary *responseObject) {
                
            } fail:^{
                
            }];
        }
            break;
        case 8:
        {
            [BIgeyesRequest userLoginWithAreaCode:@"" phoneNumber:@"" code:@"" success:^(NSDictionary *responseObject) {
                
            } fail:^{
                
            }];
        }
            break;
            case 9:
        {
            [BIgeyesRequest tokenWithSessionId:@"" success:^(NSDictionary *responseObject) {
                
            } fail:^{
                
            }];
        }
            break;
            case 10:
        {
            [BIgeyesRequest userlogoutWithSessionId:@"" success:^(NSDictionary *responseObject) {
                
            } fail:^{
                
            }];
        }
            break;
        case 11:
        {
            [BIgeyesRequest contactsUploadWithIdentityId:@"" areaCode:@"" contacts:@[] success:^(NSDictionary *responseObject) {
                
            } fail:^{
                
            }];
        }
            break;
            case 12:
        {
            [BIgeyesRequest faceSearchWithIdentityId:@"" image:@[] success:^(NSDictionary *responseObject) {
                
            } fail:^{
                
            }];
        }
            break;
        case 13:
        {
            [BIgeyesRequest photoSendWithIdentityId:@"" image:@{} receivers:@[] success:^(NSDictionary *responseObject) {
                
            } fail:^{
                
            }];
        }
            break;
        case 14:
        {
            [BIgeyesRequest photoAutosendWithIdentityId:@"" imageKey:@"" success:^(NSDictionary *responseObject) {
                
            } fail:^{
                
            }];
        }
            break;
        case 15:
        {
            [BIgeyesRequest photoReceiveWithIdentityId:@"" success:^(NSDictionary *responseObject) {
                
            } fail:^{
                
            }];
        }
            break;
        case 16:
        {
            [BIgeyesRequest photoReceiptWithIdentityId:@"" success:^(NSDictionary *responseObject) {
                
            } fail:^{
                
            }];
        }
            break;
        case 17:
        {
            [BIgeyesRequest photoReject:@"" deliverIds:@[] success:^(NSDictionary *responseObject) {
                
            } fail:^{
                
            }];
        }
            break;
        case 18:
        {
            [BIgeyesRequest photoConfirm:@"" deliverIds:@[] success:^(NSDictionary *responseObject) {
                
            } fail:^{
                
            }];
        }
            break;
        case 19:
        {
            [BIgeyesRequest friendsWithIdentityId:@"" success:^(NSDictionary *responseObject) {
                
            } fail:^{
                
            }];
        }
            break;
        case 20:
        {
            [BIgeyesRequest friendsRadarWithIdentityId:@"" ssid:@"" lat:@"" lng:@"" success:^(NSDictionary *responseObject) {
                
            } fail:^{
                
            }];
        }
            break;
        case 21:
        {
            [BIgeyesRequest friendsAddWithIdentityId:@"" uids:@[] success:^(NSDictionary *responseObject) {
                
            } fail:^{
                
            }];
        }
            break;
        case 22:
        {
            [BIgeyesRequest settingsSetWithIdentityId:@"" is34G:@"" sendNet:@"" receiveNet:@"" notification:@"" isAutoShare:@"" isAutoShareFullImage:@"" isShowPhoneNumber:@"" success:^(NSDictionary *responseObject) {
                
            } fail:^{
                
            }];
        }
            break;
        case 23:
        {
            [BIgeyesRequest friendInviteWithIdentityId:@"" areaCode:@"" contacts:@[] success:^(NSDictionary *responseObject) {
                
            } fail:^{
                
            }];
        }
            break;
            case 24:
        {
            [BIgeyesRequest imageUploadWithIdentityId:@"" image:[UIImage new]];
        }
            break;
        default:
            break;
    }
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end

















